import Vue from 'vue'
import Router from 'vue-router'

/* Layout */
import Layout from '../views/layout/Layout'

const _import = require('./_import_' + process.env.NODE_ENV)
// in development-env not use lazy-loading, because lazy-loading too many pages will cause webpack hot update too slow. so only in production use lazy-loading;
// detail: https://panjiachen.github.io/vue-element-admin-site/#/lazy-loading

Vue.use(Router)

export const componentMap = {
  'Layout': Layout,
  'SubLayout': { render(c) { return c('router-view') } },
  'page401': _import('errorPage/401'),
  'page404': _import('errorPage/404'),
  'original': _import('article/original'),
  'list': _import('article/list'),
  'intelligence': _import('article/intelligence'),
  'robotWriter': _import('article/robotWriter'),
  'integratedSearch': _import('article/IntegratedSearch'),
  'columnList': _import('column/list'),
  'keyword': _import('word/keyword'),
  'sensitive': _import('word/sensitive'),
  'dengtaKeyword': _import('word/dengtaKeyword'),
  'dengtaSensitive': _import('word/dengtaSensitive'),
  'groupIndustry': _import('group/industry'),
  'groupConcept': _import('group/concept'),
  'groupOriginal': _import('group/original'),
  'groupPlate': _import('group/plate'),
  'database': _import('data/database'),
  'dataSource': _import('data/dataSource'),
  'dataSourceMonitor': _import('data/dataSourceMonitor'),
  'newStatistics': _import('dataStatistics/newStatistics'),
  'newsHotop': _import('dataStatistics/newsHotop'),
  'publicStatistics': _import('dataStatistics/publicStatistics'),
  'dictionary': _import('systemManagement/dictionary'),
  'permission': _import('systemManagement/permission'),
  'tagCompiler': _import('systemManagement/tagCompiler'),
  'operationRecord': _import('systemManagement/operationRecord'),
  'imageKeywords': _import('imageManagement/imageKeywords'),
  'gallery': _import('imageManagement/gallery'),
  'columnImages': _import('imageManagement/columnImages'),
  'announcement': _import('announcementManagement/announcement'),
  'knownEvtManage': _import('events/eventsManage/knownEvtManage'),
  'unknownEvtManage': _import('events/eventsManage/unknownEvtManage'),
  'hotManage': _import('events/hotManage'),
  'themeManage': _import('events/themeManage'),
  'parameterDict': _import('toolManage/parameterDict'),
  'calendar': _import('toolManage/calendar'),
  'blackList': _import('word/newWordManage/blackList'),
  'newWordFound': _import('word/newWordManage/newWordFound'),
  'sanmeLabels': _import('word/newWordManage/sanmeLabels'),
  'labelDisambiguation': _import('word/labelDisambiguation'),
  'equityThrough': _import('knowledgeMap/equityThrough'),
  'equityRelat': _import('knowledgeMap/equityRelat'),
  'recommend': _import('infoRecommend/recommend'),
  'userRecmdInfo': _import('infoRecommend/userRecmdInfo'),
  'myProject': _import('project/myProject'),
  'projectList': _import('project/projectList'),
  'intelligencSetting': _import('intelligenceAdvice/setting'),
  'intelligencShow': _import('intelligenceAdvice/firstComeinShow')
}

/** note: submenu only apppear when children.length>=1
 *   detail see  https://panjiachen.github.io/vue-element-admin-site/#/router-and-nav?id=sidebar
 **/

/**
 * hidden: true                   if `hidden:true` will not show in the sidebar(default is false)
 * redirect: noredirect           if `redirect:noredirect` will no redirct in the breadcrumb
 * name:'router-name'             the name is used by <keep-alive> (must set!!!)
 * meta : {
    roles: ['admin','editor']     will control the page roles (you can set multiple roles)
    title: 'title'               the name show in submenu and breadcrumb (recommend set)
    icon: 'svg-name'             the icon show in the sidebar,
    noCache: true                if fasle ,the page will no be cached(default is false)
  }
 **/
export const constantRouterMap = [
  { path: '/login', component: _import('login/index'), hidden: true },
  { path: '/authredirect', component: _import('login/authredirect'), hidden: true },
  { path: '/404', component: _import('errorPage/404'), hidden: true },
  { path: '/401', component: _import('errorPage/401'), hidden: true },
  {
    path: '',
    component: Layout,
    redirect: 'homepage',
    meta: {
      icon: 'component',
      title: '首页'
    },
    Icon: 'el-icon-share',
    children: [{
      path: 'homepage',
      component: _import('admin/homepage'),
      name: 'homepage',
      Icon: 'el-icon-share',
      meta: { title: '首页', icon: 'component', noCache: false }
    }]
  },
  {
    path: '/labelManagement',
    component: Layout,
    redirect: 'noredirect',
    name: 'labelManagement',
    Icon: 'el-icon-menu',
    meta: {
      icon: 'component',
      title: '标签管理',
      noCache: false
    },
    children: [{
      path: 'stockProperty',
      component: _import('labelManagement/stockProperty'),
      name: 'stockProperty',
      meta: { title: '股票属性', noCache: false }
    },
    {
      path: 'fundProperty',
      component: _import('labelManagement/fundProperty'),
      name: 'fundProperty',
      meta: { title: '基金属性', noCache: false }
    },
    {
      path: 'themeProperty',
      component: _import('labelManagement/themeProperty'),
      name: 'themeProperty',
      meta: { title: '主题属性', noCache: false }
    },
    {
      path: 'industryProperty',
      component: _import('labelManagement/industryProperty'),
      name: 'industryProperty',
      meta: { title: '行业属性', noCache: false }
    },
    {
      path: 'marketProperty',
      component: _import('labelManagement/marketProperty'),
      name: 'marketProperty',
      meta: { title: '市场属性', noCache: false }
    }, {
      path: 'peopleProperty',
      component: _import('labelManagement/peopleProperty'),
      name: 'peopleProperty',
      meta: { title: '人物属性', noCache: false }
    }, {
      path: 'districtsProperty',
      component: _import('labelManagement/districtsProperty'),
      name: 'districtsProperty',
      meta: { title: '地域属性', noCache: false }
    }, {
      path: 'organizeProperty',
      component: _import('labelManagement/organizeProperty'),
      name: 'organizeProperty',
      meta: { title: '组织属性', noCache: false }
    }
    ]
  }
  // {
  //   path: '/integrated',
  //   component: Layout,
  //   redirect: 'integratedAdvice',
  //   name: 'integrated',
  //   meta: {
  //     icon: 'component',
  //     title: '智能推荐'
  //   },
  //   children: [{
  //     path: 'integratedAdvice',
  //     component: _import('intelligenceAdvice/setting'),
  //     name: 'integratedAdvice',
  //     meta: { title: '推荐设置', icon: 'component', noCache: false }
  //   }, {
  //     path: 'show',
  //     component: _import('intelligenceAdvice/firstComeinShow'),
  //     name: 'intelligencShow',
  //     meta: { title: '推荐展示', icon: 'component', noCache: false }
  //   }]
  // }
  // {
  //     path: '/articles',
  //     component: Layout,
  //     redirect: 'noredirect',
  //     name: 'articles',
  //     meta: {
  //         icon: 'component',
  //         title: '资讯管理'
  //     },
  //     children: [{
  //         path: 'IntegratedSearch',
  //         component: _import('article/IntegratedSearch'),
  //         name: 'IntegratedSearch',
  //         meta: { title: '综合查询', icon: 'component', noCache: false }
  //     }]
  // }
]

export default new Router({
  // mode: 'history', // require service support
  scrollBehavior: () => ({ y: 0 }),
  routes: constantRouterMap
})

export const asyncRouterMap = [{
  path: '/imageManagement',
  component: Layout,
  redirect: 'noredirect',
  name: 'imageManagement',
  meta: {
    title: '配图管理',
    icon: 'international'
  },
  children: [{
    path: 'gallery',
    component: _import('imageManagement/gallery'),
    name: 'gallery',
    meta: { title: '图库管理', noCache: true }
  },
  {
    path: 'columnImages',
    component: _import('imageManagement/columnImages'),
    name: 'columnImages',
    meta: { title: '栏目配图管理', noCache: true }
  },
  {
    path: 'imageKeywords',
    component: _import('imageManagement/imageKeywords'),
    name: 'imageKeywords',
    meta: { title: '配图词汇标签管理', noCache: true }
  }
  ]
},
{
  path: '/systemManagement',
  component: Layout,
  redirect: 'noredirect',
  name: 'systemManagement',
  meta: {
    title: '系统管理',
    icon: 'international'
  },
  children: [{
    path: 'dictionary',
    component: _import('systemManagement/dictionary'),
    name: 'dictionary',
    meta: { title: '数据字典菜单', noCache: true }
  },
  {
    path: 'permission',
    component: _import('systemManagement/permission'),
    name: 'permission',
    meta: { title: '用户栏目管理', noCache: true }
  },
  {
    path: 'tagCompiler',
    component: _import('systemManagement/tagCompiler'),
    name: 'tagCompiler',
    meta: { title: '标签润色管理', noCache: true }
  },
  {
    path: 'operationRecord',
    component: _import('systemManagement/operationRecord'),
    name: 'operationRecord',
    meta: { title: '操作流水', noCache: true }
  }
  ]
},
{
  path: '/originalArticle',
  component: Layout,
  redirect: 'noredirect',
  name: 'originalArticle',
  meta: {
    title: '原创资讯',
    icon: 'international'
  },
  children: [{
    path: 'original',
    component: _import('article/original'),
    name: 'original',
    meta: { title: '我的原创资讯', noCache: true }
  },
  {
    path: 'list',
    component: _import('article/list'),
    name: 'list',
    meta: { title: '资讯列表', noCache: true }
  }
  ]
},
{
  path: '/intelligenceArticle',
  component: Layout,
  redirect: 'noredirect',
  name: 'intelligenceArticle',
  meta: {
    title: '智能资讯',
    icon: 'international'
  },
  children: [{
    path: 'intelligence',
    component: _import('article/intelligence'),
    name: 'intelligence',
    meta: { title: '智能资讯', noCache: true }
  }]
},
{
  path: '/column',
  component: Layout,
  redirect: 'noredirect',
  name: 'column',
  meta: {
    title: '栏目管理',
    icon: 'component'
  },
  children: [{
    path: 'columnList',
    component: _import('column/list'),
    name: 'columnList',
    meta: { title: '栏目列表', noCache: true }
  }]
},
{
  path: '/word',
  component: Layout,
  redirect: 'noredirect',
  name: 'word',
  meta: {
    title: '词汇管理',
    icon: 'form'
  },
  children: [{
    path: 'keyword',
    component: _import('word/keyword'),
    name: 'keyword',
    meta: { title: '词汇管理', noCache: true }
  }, {
    path: 'sensitive',
    component: _import('word/sensitive'),
    name: 'sensitive',
    meta: { title: '敏感词管理', noCache: true }
  }, {
    path: 'dengtaKeyword',
    component: _import('word/dengtaKeyword'),
    name: 'dengtaKeyword',
    meta: { title: '灯塔词汇管理', noCache: true }
  }, {
    path: 'dengtaSensitive',
    component: _import('word/dengtaSensitive'),
    name: 'dengtaSensitive',
    meta: { title: '灯塔敏感词管理', noCache: true }
  }]
},
{
  path: '/group',
  component: Layout,
  redirect: 'noredirect',
  name: 'group',
  meta: {
    title: '板块管理',
    icon: 'form'
  },
  children: [{
    path: 'groupIndustry',
    component: _import('group/industry'),
    name: 'groupIndustry',
    meta: { title: '行业板块', noCache: true }
  }, {
    path: 'groupConcept',
    component: _import('group/concept'),
    name: 'groupConcept',
    meta: { title: '概念板块', noCache: true }
  }, {
    path: 'groupOriginal',
    component: _import('group/original'),
    name: 'groupOriginal',
    meta: { title: '原创板块', noCache: true }
  }]
},
{
  path: '/data',
  component: Layout,
  redirect: 'noredirect',
  name: 'data',
  meta: {
    title: '数据源管理',
    icon: 'form'
  },
  children: [{
    path: 'database',
    component: _import('data/database'),
    name: 'database',
    meta: { title: '数据库管理', noCache: true }
  }, {
    path: 'dataSource',
    component: _import('data/dataSource'),
    name: 'dataSource',
    meta: { title: '数据源管理', noCache: true }
  }, {
    path: 'dataSourceMonitor',
    component: _import('data/dataSourceMonitor'),
    name: 'dataSourceMonitor',
    meta: { title: '数据源监控', noCache: true }
  }]
},
{
  path: '/data',
  component: Layout,
  redirect: 'noredirect',
  name: 'data',
  meta: {
    title: '数据源管理',
    icon: 'form'
  },
  children: [{
    path: 'database',
    component: _import('data/database'),
    name: 'database',
    meta: { title: '数据库管理', noCache: true }
  }]
},
{ path: '*', redirect: '/404', hidden: true }
]
